package com.example.onedemotest;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.LocalRemoteObject;
import ohos.aafwk.content.Intent;
import ohos.rpc.IRemoteObject;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

/**
 * 测试 service
 */
public class ServiceAbility extends Ability {
    private static final HiLogLabel LABEL_LOG = new HiLogLabel(HiLog.LOG_APP, 0xD001100, "ServiceAbility");

    @Override
    public void onStart(Intent intent) {
        HiLog.error(LABEL_LOG, "ServiceAbility::onStart");
        super.onStart(intent);
    }

    @Override
    public void onBackground() {
        HiLog.info(LABEL_LOG, "ServiceAbility::onBackground");
        super.onBackground();
    }

    @Override
    protected void onInactive() {
        HiLog.info(LABEL_LOG, "ServiceAbility::onInactive");
        super.onInactive();
    }

    @Override
    protected void onActive() {
        HiLog.info(LABEL_LOG, "ServiceAbility::onActive");
        super.onActive();
    }

    @Override
    public void onStop() {
        HiLog.info(LABEL_LOG, "ServiceAbility::onStop");
        super.onStop();
    }

    @Override
    public void onCommand(Intent intent, boolean restart, int startId) {
        HiLog.error(LABEL_LOG, "ServiceAbility::onCommand");
    }

    @Override
    public IRemoteObject onConnect(Intent intent) {
        HiLog.error(LABEL_LOG, "ServiceAbility::onConnect");
        return new MyLocalRemoteObject();
    }

    @Override
    public void onDisconnect(Intent intent) {
        HiLog.error(LABEL_LOG, "ServiceAbility::onDisconnect");
    }

    public class MyLocalRemoteObject extends LocalRemoteObject {
        public MyLocalRemoteObject() {
            HiLog.error(LABEL_LOG, "ServiceAbility::MyLocalRemoteObject");
        }
    }
}